package com.example.demo.controller;


import com.example.demo.model.PsLine;
import com.example.demo.repository.LineRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class LineController {

    @Autowired
    private LineRepository lineRepository;



    @GetMapping("/getLine")
    public List<PsLine> getPoint(@RequestParam Double coorx, @RequestParam Double coory, @RequestParam Integer distance) {
        List<PsLine> lineList = lineRepository.getLine(coorx, coory, distance);
        return lineList;
    }

    @GetMapping("/getLineByExtent")
    public List<PsLine> getPointByExtent(@RequestParam Double minx, @RequestParam Double miny, @RequestParam Double maxx, @RequestParam Double maxy) {
        List<PsLine> lineList = lineRepository.getLineByExtent(minx, miny, maxx, maxy);
        return lineList;
    }


    @PostMapping("/updateLine")
    public Boolean addUser(@RequestParam(value = "gid", required = true) Integer gid,@RequestParam(value = "geom", required = true) String geom) {
        return lineRepository.updateGeom(gid,geom);
    }

}

